package com.qf.rbac2202.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.qf.rbac2202.annotation.DataFilter;
import com.qf.rbac2202.sys.entity.SysDept;
import com.qf.rbac2202.sys.mapper.SysDeptMapper;
import com.qf.rbac2202.sys.service.ISysDeptService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.rbac2202.utils.Constants;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 部门管理 服务实现类
 * </p>
 *
 * @author dong_
 * @since 2022-10-28
 */
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {

	@Transactional(propagation = Propagation.SUPPORTS)
	@Override
	@DataFilter(dataFieldName="dept_id")
	public List< SysDept > queryDeptMap( Map< String, String > params ) {

		QueryWrapper< SysDept > sysDeptQueryWrapper=new QueryWrapper<>( );
		String s=params.get( Constants.DATA_FILETER );
		sysDeptQueryWrapper.apply( StringUtils.isNotBlank(s),s );

		return this.list(sysDeptQueryWrapper);
	}
}
